


#ifndef PF_PATTERNLIST_H
#define PF_PATTERNLIST_H


#include "pf_pattern.h"
#include "pf_entity.h"
#include "lx_Export.h"

#define PF_PATTERNLIST PF_PatternList::instance()

/**
 * The global list of patterns. This is implemented as a singleton.
 * Use PF_PatternList::instance() to get a pointer to the object.
 *

 */
class LX_EXPORT PF_PatternList {
protected:
    PF_PatternList();

public:
    /**
     * @return Instance to the unique pattern list.
     */
    static PF_PatternList* instance() {
        if (uniqueInstance==NULL) {
            uniqueInstance = new PF_PatternList();
        }
        return uniqueInstance;
    }

    virtual ~PF_PatternList() {clearPatterns();}

    void init();

    void clearPatterns();
    int countPatterns() {
        return patterns.count();
    }
    virtual void removePattern(PF_Pattern* pattern);
    PF_Pattern* requestPattern(const QString& name);
    //! @return a const iterator for the pattern list.
    QListIterator<PF_Pattern *> getIteretor(){
        return QListIterator<PF_Pattern *>(patterns);
    }

        bool contains(const QString& name);

    //void addPatternListListener(PF_PatternListListener* listener);

    friend std::ostream& operator << (std::ostream& os, PF_PatternList& l);

    //static bool test();

protected:
    static PF_PatternList* uniqueInstance;

private:
    //! patterns in the graphic
    QList<PF_Pattern*> patterns;
    //! List of registered PatternListListeners
    //QList<PF_PatternListListener> patternListListeners;
}
;

#endif
